<style lang="scss" scoped>
.operate-exam-container ::v-deep {
    .el-breadcrumb__item:last-child ::v-deep {
        .el-breadcrumb__inner {
            color: #606266;
            font-weight: bold;
            cursor: default;
        }
    }
    .el-breadcrumb__item ::v-deep {
        .is-link {
            color: #aaa;
            font-weight: unset;
        }
        .is-link:hover {
            color: #409eff;
        }
    }
    .exam-form {
        padding-right: 10px;
    }
    .exam-form ::v-deep {
        .el-date-editor.el-input {
            width: 100% !important;
        }
        .editor-custom-btn-container {
            display: none;
        }
        .tinymce-container {
            margin: 0 !important;
        }
    }
    .title {
        font-size: 18px;
    }
    .el-divider--horizontal {
        margin: 10px 0 20px 0 !important;
    }
    .operate-btn-container {
        border-top: 1px solid #ebeef5;
        padding: 20px;
        margin-bottom: 30px;
    }
}
</style>
<template>
    <div class="operate-exam-container">
      <div v-if="indexKey === 1">
        <div style="height: 30px;">
            <el-breadcrumb style="float: left;" separator="/">
                <el-breadcrumb-item :to="{ path: '/projectDeclaration' }">
                    <span @click="reback()" >{{ $t('projectDeclara.competiProjectAdd') }}</span>
                </el-breadcrumb-item>
                <el-breadcrumb-item>{{ $t('interdisciplinaryManagement.increased') }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-card
            style="padding: 0!important;"
            shadow="never"
            v-loading="loading"
            body-style="padding: 24px;" >
            <el-row type="flex" class="row-bg" justify="space-between">
              <!-- <span>{{$t('projectDeclara.competiDeclara')}}</span> -->
              <h2>{{$t('collegeFirstTrial.projectDeclara')+'-'+ compile}}</h2>
              <el-button @click="reback">{{$t('requirement.back')}}</el-button>
            </el-row>
            <hr>
            <h2 style="color:#101010" >{{$t('projectDeclara.competitProject')}}</h2>
            
            <el-form :model="queryForm" ref='formName' :rules="rules" label-suffix="：" >
              <el-row :span="24" style="margin-bottom: 15px;">
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.competition')" prop="typeId" label-width="150px">
                    <el-select v-model="queryForm.typeId" clearable filterable style="width:70%">
                      <el-option
                        v-for="item in options.country"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                    <el-tooltip  placement="bottom" effect="light">
                      <div slot="content">
                          <div>
                            <span v-for="(el,index) in options.country" :key='index'>
                              <div >{{index+1 +'. '+ el.name+'：'+ el.remark}}</div>
                            </span>
                          </div>
                        </div>
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.competiProject')" prop="name" label-width="150px">
                    <el-input v-model="queryForm.name" clearable maxlength="64"  style="width:70%"></el-input>
                    <el-tooltip content="年份+申报参加的竞赛项目完整名称"  placement="bottom" effect="light">
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.competiLevel')" prop="comLevel" label-width="150px">
                    <el-select v-model="queryForm.comLevel" clearable  style="width:70%">
                      <el-option
                        v-for="item in options.degreeType"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                    <el-tooltip content="国际级、国家级、省市级、校级（如有晋级赛，填写最高等级申报一次）" placement="bottom" effect="light">
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.sponsor')" prop="organizer" label-width="150px">
                    <el-input v-model="queryForm.organizer" maxlength="64" clearable type="textarea" :rows="1" style="width:70%"></el-input>
                    <el-tooltip content="指项目的发起单位指导、协调、把关" placement="bottom" effect="light">
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.organizer')" prop="undertaker" label-width="150px">
                    <el-input v-model="queryForm.undertaker" maxlength="64"  type="textarea" :rows="1" clearable  style="width:70%"></el-input>
                    <el-tooltip content="本年度赛事承办高校或者其他组织单位，负责赛事活动的策划与组织实施"  placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.matchTime')" prop="comStartArr" label-width="150px">
                    <!-- <el-date-picker style="width:70%"
                      v-model="queryForm.comStart"
                      type="month"
                      value-format="yyyy-MM"
                      format="yyyy-MM"
                      >
                    </el-date-picker> -->
                    <el-date-picker
                      v-model="queryForm.comStartArr"
                      type="monthrange"
                      value-format="yyyy-MM"
                      start-placeholder="开始月份"
                      end-placeholder="结束月份"
                      style="width:70%">
                    </el-date-picker>
                    <el-tooltip content="当年度比赛时间区间"  placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.competiSite')" prop="comPlace" label-width="150px">
                    <el-input v-model="queryForm.comPlace" maxlength="64" clearable  style="width:70%"></el-input>
                    <el-tooltip content="预计比赛的地点"  placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.compeObject')" prop="competitor" label-width="150px">
                    <!-- <el-input v-model="queryForm.competitor" maxlength="64" clearable  style="width:70%"></el-input> -->
                    <el-select v-model="queryForm.competitor" clearable  style="width:70%">
                      <el-option
                        v-for="item in options.participant"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                    <el-tooltip content="本校本科生、研究生或本科生及研究生（本科生院支持经费主要用于本科生参加赛事）" placement="bottom" effect="light">
                     
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.entryForm')" prop="comForm" label-width="150px">
                    <!-- <el-input v-model="queryForm.comForm" maxlength="64" clearable  style="width:70%"></el-input> -->
                    <el-select v-model="queryForm.comForm" clearable  style="width:70%">
                      <el-option
                        v-for="item in options.competit"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                    <el-tooltip content="团体赛或者个人参赛"  placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.participants')" prop="selectNumber" label-width="150px">
                    <el-input v-model="queryForm.selectNumber" maxlength="10" clearable  style="width:70%"></el-input>
                    <el-tooltip content="在对外报名之前校内报名人数筛选" placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.participate')" prop="teamNumber" label-width="150px">
                    <el-input v-model="queryForm.teamNumber" maxlength="10" clearable  style="width:70%"></el-input>
                    <el-tooltip content="预计组队参加的队伍数"  placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.participantsNumber')" prop="peopleNumber" label-width="150px">
                    <el-input v-model="queryForm.peopleNumber" maxlength="10" clearable  style="width:70%"></el-input>
                    <el-tooltip content="计划组队的总人数" placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item :label="$t('projectDeclara.director')" prop="comManager" label-width="150px">
                    <el-select
                      v-model="queryForm.comManager"
                      filterable
                      remote
                      style="width:70%"
                      clearable
                      reserve-keyword
                      :placeholder="$t('collegeSetup.numberQuery')"
                      :remote-method="remoteMethodOne"
                      >
                      <el-option v-for="item in options.approver"
                          :key="item.code"
                          :label="item.name"
                          :value="item.code" >
                    
                      <span style="float: left">{{ item.name }}</span>
                      <span style="float: right; color: #8492a6; font-size: 13px" >{{ item.code }}</span>
                      </el-option>
                    </el-select>
                    <el-tooltip content="整个赛事的负责人" placement="bottom" effect="light">
                      
                      <img :src="images" alt="" >
                    </el-tooltip>
                    <!-- <el-input v-model="queryForm.comManager" maxlength="64" clearable  style="width:70%"></el-input> -->
                  </el-form-item>
                </el-col>
                <el-col :span="8" >
                  <el-form-item :label="$t('projectDeclara.competiPlan')" label-width="150px">
                    <el-radio-group v-model="radio" @change="competiPlan">
                      <el-radio label="1" >是</el-radio>
                      <el-radio label="2" >否</el-radio>
                    </el-radio-group>
                      <el-tooltip content="参加竞赛项目有没有对应新开或改建的竞教结合课程" placement="bottom" effect="light">
                        <img :src="images" alt="" >
                      </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="radioList">
                  <el-form-item  :label="$t('projectDeclara.competitCourse')" prop="" label-width="150px" >
                    <el-input  v-model="queryForm.course" maxlength="32" clearable  style="width:70%"></el-input>
                    <el-button @click="addDomain">{{$t('projectDeclara.save')}}</el-button>
                    <el-tooltip placement="bottom" effect="light">
                      <div slot="content">
                      竞教结合课程名称，或者相关度高的课程名称，
                      {{$t('projectDeclara.continue')}}
                      </div>
                      <img :src="images" alt="" >
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <!-- this.queryForm.courseList -->
                  <edu-table v-if="queryForm.courseList.length>0"
                    :pagination="false"
                    :selection="false"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :data="queryForm.courseList"
                    size="mini">
                    <edu-table-column :label="$t('projectDeclara.competitCourse')" prop="course" > </edu-table-column>
                    <edu-table-column :label="$t('common.text.operation')" fit width="150">
                      <template slot-scope="props">
                        <el-button type="text"  @click="courseResubmit(props.row,props.$index)">{{$t('projectDeclara.delete')}}</el-button>
                      </template>
                    </edu-table-column>
                  </edu-table>
              </el-row>

            <span style="color:#101010;font-size: 18px;" >{{$t('projectDeclara.lastResults')}}</span>
              <el-tooltip  placement="bottom" effect="light">
                <div slot="content">
                  上一次参加比赛取得的成绩，各等级获奖项数及获奖人次数，
                  {{$t('projectDeclara.continue')}}
                  </div>
                <img :src="images" alt="" >
              </el-tooltip>
              <edu-table style="margin-top:10px"
                  :pagination="false"
                  :selection="false"
                  :tooltipEffect="tooltipEffect"
                  stripe
                  :data="queryForm.lastScoreList"
                  size="mini">
                <edu-table-column :label="$t('projectDeclara.awardName')" prop="name" >
                  <template slot-scope="scope">
                      <el-form-item v-if="!scope.row.flag"  >
                        <el-select @change="changeAwardName(scope.row, $event)" v-model="scope.row.name" style="margin-top: 15px;width:100%" :prop="'lastScoreList.' + scope.$index + '.name'" label-width="0" :rules="rulesForm.name">
                          <el-option 
                            v-for="item in options.awardName"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <span v-if="scope.row.flag">{{scope.row.name}}</span>
                  </template>
                </edu-table-column>
                <edu-table-column  prop='names'>
                  <template slot-scope="scope" >
                      <el-form-item v-if="scope.row.code==99&&!scope.row.flag" style="margin-top: 15px;" >
                        <el-input
                            v-model.trim="scope.row.names"
                            clearable :placeholder="$t('projectDeclara.enterNames')"
                            maxlength="64" >
                        </el-input>
                      </el-form-item>
                      <span  v-if="scope.row.flag">{{scope.row.names}}</span>
                  </template>
                </edu-table-column>
                <edu-table-column :label="$t('projectDeclara.winnScores')" prop="result" >
                  <template slot-scope="scope">
                      <el-form-item v-if="!scope.row.flag" style="margin-top: 15px;"  >
                      <!-- <el-form-item v-if="!scope.row.flag" style="margin-top: 15px;" :prop="'lastScoreList.' + scope.$index + '.result'" label-width="0" :rules="rulesForm.result" > -->
                        <el-input
                            v-model.trim="scope.row.result"
                            clearable
                            maxlength="64" >
                        </el-input>
                      </el-form-item>
                      <span v-else>{{scope.row.result}}</span>
                  </template>
                </edu-table-column>
                <edu-table-column :label="$t('projectDeclara.laureates')" prop="person" >
                  <template slot-scope="scope">
                      <el-form-item v-if="!scope.row.flag" style="margin-top: 15px;"  >
                      <!-- <el-form-item v-if="!scope.row.flag" style="margin-top: 15px;" :prop="'lastScoreList.' + scope.$index + '.result'" label-width="0" :rules="rulesForm.result" > -->
                        <el-input
                            v-model.trim="scope.row.person"
                            clearable
                            maxlength="64" >
                        </el-input>
                      </el-form-item>
                      <span v-else>{{scope.row.person}}</span>
                  </template>
                </edu-table-column>
                <edu-table-column :label="$t('common.text.operation')" fit width="150">
                  <template slot-scope="props">
                    <el-button type="text" v-if="!props.row.flag"  @click="internAssignment(props.row,props.$index)">{{$t('projectDeclara.save')}}</el-button>
                    <el-button type="text" v-if="props.row.flag" @click="submitResults(props.row,props.$index)">{{$t('projectDeclara.compile')}}</el-button>
                    <el-button type="text" v-if="props.row.flag" @click="selectEvalResubmit(props.row,props.$index)">{{$t('projectDeclara.delete')}}</el-button>
                  </template>
                </edu-table-column>
              </edu-table>
              <div style="margin-top:20px">
                <el-form-item :label="$t('projectDeclara.shouldExceed')" prop="content">
                  <el-tooltip placement="top" effect="light">
                    <div slot="content">
                        <div >
                          <span v-for="(el,index) in shouldExceed" :key='index'>
                            <div >{{el.remark}}</div>
                          </span>
                        </div>
                      </div>
                    <img :src="images" alt="" style="margin-top:8px">
                  </el-tooltip>
                <el-input
                  type="textarea"
                  :rows="5"
                  maxlength="10000"
                  :placeholder="$t('projectDeclara.pleaseEnter')"
                  v-model="queryForm.content">
                </el-input>
                </el-form-item>
              </div>
              <div style="margin-top:20px">
                <el-form-item :label="$t('projectDeclara.implementat')" prop="implementCondition">
                  <el-tooltip placement="top" effect="light">
                    <div slot="content">
                        <div >
                          <span v-for="(el,index) in implementat" :key='index'>
                            <div >{{el.remark}}</div>
                          </span>
                        </div>
                      </div>
                    <img :src="images" alt="" style="margin-top:8px">
                  </el-tooltip>
                <el-input
                  type="textarea"
                  maxlength="10000"
                  :rows="5"
                  :placeholder="$t('projectDeclara.pleaseEnter')"
                  v-model="queryForm.implementCondition">
                </el-input>
                </el-form-item>
              </div>
              <div style="margin-top:20px">
                <el-form-item :label="$t('projectDeclara.shouldtContents')" prop="implementContent">
                  <el-tooltip placement="top" effect="light">
                    <div slot="content">
                        <div >
                          <span v-for="(el,index) in shouldtContents" :key='index'>
                            <div >{{el.remark}}</div>
                          </span>
                        </div>
                      </div>
                    <img :src="images" alt="" style="margin-top:8px">
                  </el-tooltip>
                <el-input
                  type="textarea"
                  :rows="5"
                  maxlength="10000"
                  :placeholder="$t('projectDeclara.pleaseEnter')"
                  v-model="queryForm.implementContent">
                </el-input>
                </el-form-item>
              </div>
              <div style="margin-top:20px">
                <el-form-item :label="$t('projectDeclara.shouldtProgress')" prop="progressPlan">
                  <el-tooltip content="项目进度及计划安排" placement="top" effect="light">
                    <img :src="images" alt="" style="margin-top:8px">
                  </el-tooltip>
                <el-input
                  type="textarea"
                  :rows="5"
                  maxlength="10000"
                  :placeholder="$t('projectDeclara.pleaseEnter')"
                  v-model="queryForm.progressPlan">
                </el-input>
                </el-form-item>
              </div>
              <div style="margin-top:20px">
                <el-form-item :label="$t('projectDeclara.shouldtRaini')" prop="trainingEffect">
                  <el-tooltip placement="top" effect="light">
                    <div slot="content">
                        <div >
                          <span v-for="(el,index) in shouldtRaini" :key='index'>
                            <div >{{el.remark}}</div>
                          </span>
                        </div>
                      </div>
                    <img :src="images" alt="" style="margin-top:8px">
                  </el-tooltip>
                <el-input
                  type="textarea"
                  :rows="5"
                  maxlength="10000"
                  :placeholder="$t('projectDeclara.pleaseEnter')"
                  v-model="queryForm.trainingEffect">
                </el-input>
                </el-form-item>
              </div>
              <h2 style="color:#101010" >{{$t('approveBudget.appropriation')}}</h2>
              <projectDeclarationAddTab @changeTabe='clickTabe' :compile='compile' @change-value='changeValue' :compileSave='compileSave'></projectDeclarationAddTab>
              <el-row type="flex" justify="end">
                <el-button @click="reback">{{$t('common.btn.cancel')}}</el-button>
                <el-button type="primary" @click="save('保存')">{{$t('projectDeclara.save')}}</el-button>
                <el-button type="primary" @click="determine">{{$t('projectScore.submit')}}</el-button>
              </el-row>
            </el-form>
        </el-card>
      </div>
        
    </div>
</template>
<script>
import { queryDic } from 'common/src/api/dictionary'
import UTILS from 'common/src/utils/utils'
import competiManagementApi from 'common/src/api/subjectCompetition/competiManagement';
import projectApplicaApi from 'common/src/api/subjectCompetition/projectApplica';
import { findTeacherInfoList } from 'common/src/api/studentinfo'

import projectDeclarationAddTab from './projectDeclarationAddTab'
export default {
  components: {
    projectDeclarationAddTab
  },
    props: {
        compile: {
            type: String,
            default: ''
        },
        dataList: {
            type: Object,
            default: () => {}
        }
    },
    data() {
        let validateNum = (rule, value, callback) => {
            // let reg = /^\d*$/
            let reg = /^[1-9][0-9]*$/
            // let reg = /^[1][3,4,5,7,8][0-9]{9}$/
            if (!reg.test(value) || value === '') {
                return callback(new Error(this.$t('expertGroupSett.pleaseNumbers')))
            }
            return callback()
        }
        let validateNumEmail = (rule, value, callback) => {
            let reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
            if (!reg.test(value) || value === '') {
                return callback(new Error(this.$t('interdisciplinaryManagement.pleaseEnter')))
            }
            return callback()
        }
        let cannotEnter = (rule, value, callback) => {
            let reg = /[`$]/im
            if (reg.test(value)) {
                return callback(new Error(this.$t('identificationToDoList.cannotContain')))
            } else if (value === '') {
                return callback(new Error(this.$t('internship.pleaseEnter')))
            }
            return callback()
        }
        return {
          indexKey: 1,
          intervalId: null,
          pickerOptionsStart: {
              disabledDate: time => {
                  let endDateVal = this.queryForm.tutorEndTime
                  if (endDateVal) {
                      // return time.getTime() > endDateVal;
                      return time.getTime() >= new Date(endDateVal).getTime()
                  }
              }
          },
          pickerOptionsEnd: {
              disabledDate: time => {
                  let beginDateVal = this.queryForm.tutorStartTime
                  if (beginDateVal) {
                      // return time.getTime() < beginDateVal;
                      return time.getTime() <= new Date(beginDateVal).getTime() - 86400000
                  }
              }
          },
          pickerStudentStart: {
              disabledDate: time => {
                  let endDateVal = this.queryForm.studentEndTime
                  if (endDateVal) {
                      // return time.getTime() > endDateVal;
                      return time.getTime() >= new Date(endDateVal).getTime()
                  }
              }
          },
          pickerStudentEndTime: {
              disabledDate: time => {
                  let beginDateVal = this.queryForm.studentStartTime
                  if (beginDateVal) {
                      // return time.getTime() < beginDateVal;
                      return time.getTime() <= new Date(beginDateVal).getTime() - 86400000
                  }
              }
          },
          variableList: '',
          images: 'static/images/icon/icon-help.png',
          // radio: '1',
          queryForm: {
            typeId: '',
            name: '',
            comLevel: '',
            organizer: '',
            undertaker: '',
            comStart: null,
            comStartArr: [], // 时间区间
            comPlace: '',
            competitor: '',
            comForm: '',
            course: '',
            comManager: '',
            selectNumber: '',
            peopleNumber: '',
            teamNumber: '',
            content: '',
            implementCondition: '',
            implementContent: '',
            progressPlan: '',
            trainingEffect: '',
            lastScoreList: [
              { name: '', result: '', flag: false,names: '',person: '',code: '', index: 0}
            ],
            courseList: [
              // {"index": 0, "course": ""}
            ],
            budgetEntityList: [],
          },
          formObjOne: {
            textarea: {
              remark: ''
            },
            list: []
          },
          formObjTow: {
            textarea: {
              remark: ''
            },
            list: []
          },
          formObjSan: {
            textarea: {
              remark: ''
            },
            list: []
          },
          remarkList: [],
          radio: '1',
          compile: '',
          compileSave: '',
          approver: [],
          id: '',
          shouldExceed: [
            {remark:'（立项依据要充分合理）'}, 
            {remark:'1.该竞赛的基本情况及竞赛内容、参赛对象'}, 
            {remark:'2.对学生基础知识、相关技能要求，我校相关课程开设、教学情况'}, 
            {remark:'3.有无竞教结合课程开课计划，及对竞教结合课程的推进作用'},
            {remark:'4.后疫情状态下如何推进竞赛项目开展'}
          ],
          implementat: [
            {remark:'（项目实施具备的时间人力物力等各方面条件。）'}, 
            {remark:'如:竞赛的组织、进程及需要的资料、设备和其他条件；竞赛的培训计划（培训要求、培训内容及时间分配、培训的重点、培训手段与方法、考核方式、培训教材及主要参考书）集中指导，分散指导，开班，点评答疑等。'}
          ],
          shouldtContents: [
            {remark:'项目建设内容要完整、全面。'}
          ],
          shouldtRaini: [
            {remark:'如经济社会效益、可持续影响指标等。'}
          ],
          options: {
              degreeType: [],
              country: [],
              approver: [],
              awardName: [],
              participant: [],
              competit: [],
              lastScoreList: []
          },
          rules: {
              name: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              comManager: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              selectNumber: [{ required: true, validator: validateNum, trigger: 'blur' }],
              teamNumber: [{ required: true, validator: validateNum, trigger: 'blur' }],
              peopleNumber: [{ required: true, validator: validateNum, trigger: 'blur' }],
              competitor: [{ required: true, message: this.$t('projectDeclara.pleaseSelect'), trigger: 'change' }],
              comPlace: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              organizer: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              undertaker: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              course: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              content: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              implementCondition: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              implementContent: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              progressPlan: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              trainingEffect: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              
              comForm: [
                  {
                      required: true,
                      message: this.$t('projectDeclara.pleaseSelect'),
                      trigger: 'change'
                  }
              ],
              typeId: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'change'
                  }
              ],
              comStart: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'change'
                  }
              ],
              comLevel: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'change'
                  }
              ],
              studentId: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'blur'
                  }
              ],
              comStartArr: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'change'
                  }
              ]
          },
          rulesForm: {
              result: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              person: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              name: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              implementContent: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              progressPlan: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              trainingEffect: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              
              studentId: [
                  {
                      required: true,
                      message: this.$t('interdisciplinaryManagement.pleaseChoose'),
                      trigger: 'blur'
                  }
              ],
              outsideTutorName: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              outsideTutorSubject: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              outsideTutorDirection: [
                  { required: true, validator: cannotEnter, trigger: 'blur' }
              ],
              outsideTutorJob: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              outsideTutorPost: [{ validator: this.validateCannotCon, trigger: 'blur' }],
              applyMoney: [{ required: true, validator: this.validateWeight, trigger: 'blur' }],
              applyMajor: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              applyDirection: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              // paperTitle: [
              //   { required: true, message: this.$t('internship.pleaseEnter'), trigger: 'blur' }
              // ],
              country: [
                  { required: true, message: this.$t('internship.pleaseEnter'), trigger: 'blur' }
              ],
              applySchoolId: [
                  { required: true, message: this.$t('internship.pleaseEnter'), trigger: 'blur' }
              ],
              disciplineDomain: [{ required: true, validator: cannotEnter, trigger: 'blur' }],
              outsideTutorOfficeholding: [{ validator: this.validateCannotCon, trigger: 'blur' }],
              studentId: [
                  { required: true, message: this.$t('internship.pleaseEnter'), trigger: 'blur' }
              ],
              teacherPhone: [{ required: true, validator: validateNum, trigger: 'change' }],
              phoneNumber: [{ required: true, validator: validateNum, trigger: 'change' }],
              outsideTeacherEmail: [
                  { required: true, validator: validateNumEmail, trigger: 'blur' }
              ],
              teacherEmail: [{ required: true, validator: validateNumEmail, trigger: 'change' }],
              email: [{ required: true, validator: validateNumEmail, trigger: 'change' }]
          }
        }
    },
    created() {
      this.intervalSave();
    },
    mounted() {
      let data = {
        pageNum_: 1,
        pageSize_: 999,
        total_: 0,
        condition: {
          name: ''
        }
      }
      competiManagementApi.projectcategoryListPage(data).then(res => {
        this.options.country = res.data.list
        this.remarkList = res.data.list
      })
      this.getOptions()
    },
    computed: {
      radioList() {
        if (this.radio=='2') {
          this.queryForm.course = ''
          this.radio = '2'
          return false
        } else {
          return this.radio = '1'
        }
      }
    },
    destroyed(){
      // 在页面销毁后，清除计时器
      this.clear();
    },
    methods: {
      competiPlan(val) {
        if (this.radio!='1') {
          this.queryForm.courseList = []
        }
      },
      intervalSave() {
        this.compileSave = '保存'
        if (this.intervalId != null) {
          return;
        }
        this.intervalId = setInterval(() => {
          this.save()
          // this.initData(); //加载数据函数
        }, 60000);
      },
      clear() {
        clearInterval(this.intervalId); //清除计时器
        this.intervalId = null; //设置为null
      },
      
      save(data) {
        // 计时器为空，操作
        // this.intervalId = setInterval(() => {
          let queryForm = JSON.parse(JSON.stringify(this.queryForm)) 
          let lastScoreList = queryForm.lastScoreList.filter(el => el.result&&el.person&&el.name)
          lastScoreList.forEach(el => {
            if (el.code == 99) {
              el.name = el.names
            }
          })
          let listOne = []
          let listTow = []
          let listSan = []
          if (this.formObjOne.list.length > 0) {
            listOne = this.formObjOne.list
            // listOne = this.formObjOne.list.filter(el => el.budget)
          }
          if (this.formObjTow.list.length > 0) {
            listTow = this.formObjTow.list
            // listTow = this.formObjTow.list.filter(el => el.budget)
          }
          if (this.formObjSan.list.length > 0) {
            listSan = this.formObjSan.list
            // listSan = this.formObjSan.list.filter(el => el.budget)
          }
          let list = listOne.concat(listTow,listSan)
          // list.push(this.formObjOne.textarea)
          // list.push(this.formObjTow.textarea)
          // list.push(this.formObjSan.textarea)
          queryForm.budgetEntityList = list
          queryForm.operateType = 0
          queryForm.id = this.id
          queryForm.lastScoreList = lastScoreList
          projectApplicaApi.projectListPageAdd(queryForm).then(res => { 
            if (data==='保存') {
              this.$message.success(this.$t('internship.successfully'));
            }
            this.id = res.data.id
          })
          // console.log("刷新" + new Date());
          // this.initData(); //加载数据函数
        // }, 60000);
        
      },
      // 工号改变获取数据
      remoteMethodOne(query) {
          if (!!query) {
              setTimeout(() => {
              findTeacherInfoList({
                  condition: query,
                  // faculty: this.form.college,
                  pageSize_: 100,
                  pageNum_: 0
              }).then(res => {
                  if (res && res.code == 200) {
                      res.data.list.forEach(row => {
                        row.name += '(' + row.code + ')';
                      })
                      this.options.approver = res.data.list
                  }
              })
              }, 200);
          } else {
              this.options.approver = []
          }
      },
      getOptions() {
        // 筛选条件字典查询
        let data = {
          lang: this.$store.getters.language || "cn",
          type: "allChild",
          keys: ["X_YX", 'G_XBIE', "JSGL_JSJB", 'G_GJQU', 'JSGL_JXMC', 'JSGL_CSDX', 'JSGL_CSXS']
          //  JSGL_JXMC  竞赛管理-奖项名称 awardName
        //  JSGL_CSDX  竞赛管理-参赛对象 participant
        //  JSGL_CSXS   竞赛管理-参赛形式 competit
        };
     
        queryDic(data).then(res => {
          if (res.code === 200) {
            this.fillSelect(res.data)
          }
        })
      },
      fillSelect(data) {
        this._fill('awardName', data.JSGL_JXMC)
        this._fill('participant', data.JSGL_CSDX)
        this._fill('competit', data.JSGL_CSXS)
        this._fill('degreeType', data.JSGL_JSJB)
      },
      _fill(type, data) {
        for (let key in data) {
          this.options[type].push({
            value: key,
            label: String(data[key])
          })
        }
      },
      addDomain() {
        if (!this.queryForm.course) {
          return this.$message.warning(this.$t('internship.pleaseEnter'))
        }
        this.queryForm.courseList.push(
          {"course": this.queryForm.course}
        )
        this.queryForm.course = ''
      },
      courseResubmit(data,index) {
        this.$delConfirm().then(() => {
          this.queryForm.courseList.splice(index,1)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('internship.cancelOpera')
          });  
        });
      },
      changeAwardName(data, att) {
        this.$set(data, 'names', '')
        this.options.awardName.forEach(el => {
          if (att==el.value) {
            this.$set(data, 'name', el.label)
            this.$set(data, 'code', att)
          }
        })
      },
      // 确定
      determine() {
        // if (this.formObjOne) {
          this.$refs['formName'].validate((valid) => {
            if (valid) {
              if (this.radio=='1') {
                if (this.queryForm.courseList.length == 0) {
                  return this.$message.warning('竞赛课程名称不能为空')
                }
              } 
              if (this.queryForm.lastScoreList.length == 1) {
                return this.$message.warning('上届比赛成绩不能为空')
              }
              let listOne = []
              let listTow = []
              let listSan = []
              if (this.formObjOne.list.length > 0) {
                listOne = this.formObjOne.list.filter(el => el.personnelCost&&el.budget&&el.remark)
              } else {
                return this.$message.warning('人员费、劳务费不能为空')
              }
              if (this.formObjTow.list.length > 0) {
                listTow = this.formObjTow.list.filter(el => el.personnelCost&&el.budget&&el.remark)
              } else {
                return this.$message.warning('图书、材料购置费不能为空')
              }
              if (this.formObjSan.list.length > 0) {
                listSan = this.formObjSan.list.filter(el => el.personnelCost&&el.budget&&el.remark)
              } else {
                return this.$message.warning('业务费不能为空')
              }
              // if (this.formObjOne.textarea) {
              //   if (!this.formObjOne.textarea.remark) {
              //     return this.$message.warning('请输入人员费、劳务费计算依据以及明细')
              //   }
              // }
              // if (this.formObjTow.textarea) {
              //   if (!this.formObjTow.textarea.remark) {
              //     return this.$message.warning('请输入图书、材料购置费计算依据以及明细')
              //   }
              // }
              // if (this.formObjSan.textarea) {
              //   if (!this.formObjSan.textarea.remark) {
              //     return this.$message.warning('请输入业务费计算依据以及明细')
              //   }
              // }
              if (listOne.length == 0) {
                return this.$message.warning('人员费、劳务费不能为空')
              }
              if (listTow.length == 0) {
                return this.$message.warning('图书、材料购置费不能为空')
              }
              if (listSan.length == 0) {
                return this.$message.warning('业务费不能为空')
              }
              let queryForm = JSON.parse(JSON.stringify(this.queryForm)) 
              queryForm.lastScoreList.forEach(el => {
                if (el.code == 99) {
                  el.name = el.names
                }
              })
              let lastScore = []
              queryForm.lastScoreList.filter(item => !item.flag).forEach(item => {
                if (item.name||item.result||item.person||item.code) {
                  lastScore.push(true)
                } else {
                  lastScore.push(false)
                }
              })
              if (lastScore.includes(true)) {
                return this.$message.warning('请检查上届比赛成绩数据是否保存或者填写完整')
              }
              let list = listOne.concat(listTow,listSan)
              // list.push(this.formObjOne.textarea)
              // list.push(this.formObjTow.textarea)
              // list.push(this.formObjSan.textarea)
              queryForm.budgetEntityList = list
              queryForm.operateType = 1
              queryForm.id = this.id
              queryForm.lastScoreList = queryForm.lastScoreList.filter(el => el.result&&el.person&&el.name)
              projectApplicaApi.projectListPageAdd(queryForm).then(res => {
                this.$message.success(this.$t('internship.successfully'));
                this.$emit('change-exam')
              })
            }
          })
      },
      clickTabe(dataOne, dataTow, dataSan) {
        this.formObjOne = dataOne
        this.formObjTow = dataTow
        this.formObjSan = dataSan
      },
      changeValue(data,dataOne, dataTow, dataSan) {
        this.queryForm.peopleSum = dataOne
        this.queryForm.purchaseSum = dataTow
        this.queryForm.businessSum = dataSan
      },
      // 保存
      internAssignment(data, index) {
        if (data.code=='99') {
          if (data.name&&data.result&&data.names&&data.person) {
            let reg = /[`$]/im
            if (reg.test(data.name)) {
              this.queryForm.lastScoreList[index].name =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            } 
            if (reg.test(data.names)) {
              this.queryForm.lastScoreList[index].names =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            } 
            if (reg.test(data.result)) {
              this.queryForm.lastScoreList[index].result =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            }
            if (reg.test(data.person)) {
              this.queryForm.lastScoreList[index].person =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            }
            this.queryForm.lastScoreList[index].flag = true
            if (this.compile !== '编辑') {
              this.queryForm.lastScoreList.push(
                { name: '', result: '',person: '', flag: false,names: '',code:'', index: index+1}
              )
            }else {
              this.compile = ''
            }
          } else {
            this.$message.warning('请检查上届比赛成绩数据是否填写完整')
          }
        } else {
          if (data.name&&data.result&&data.person) {
            let reg = /[`$]/im
            if (reg.test(data.name)) {
              this.queryForm.lastScoreList[index].name =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            } 
            if (reg.test(data.result)) {
              this.queryForm.lastScoreList[index].result =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            }
            if (reg.test(data.person)) {
              this.queryForm.lastScoreList[index].person =''
              return this.$message.warning(this.$t('identificationToDoList.cannotContain'))
            }
            this.queryForm.lastScoreList[index].flag = true
            if (this.compile !== '编辑') {
              this.queryForm.lastScoreList.push(
                { name: '', result: '',person: '', flag: false, index: index+1}
              )
            }else {
              this.compile = ''
            }
          } else {
            this.$message.warning('请检查上届比赛成绩数据是否填写完整')
          }
        }
      },
      // 编辑
      submitResults(data, index) {
        this.compile = '编辑'
        this.queryForm.lastScoreList[index].flag = false
      },
      // 删除
      selectEvalResubmit(data, index) {
        this.$delConfirm().then(() => {
          this.queryForm.lastScoreList.splice(index,1)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: this.$t('internship.cancelOpera')
          });  
        });
        
      },
      cancelOperate() {
          this.$refs['addform'].resetFields()
      },
      validateWeight(rule, value, callback) {
          if (value > 0) {
              let expReg = /^([0-9]{1,7})(\.\d{1,2})?$/
              // let expReg = /^([1-9]|[1-9]\d{1,6})(\.\d{1,3})?$/;
              if (!value) {
                  callback(new Error(this.$t('internship.pleaseEnter')))
              } else if (!expReg.test(value)) {
                  callback(new Error(this.$t('interdisciplinaryManagement.pleaseNumber')))
              } else {
                  callback()
              }
          } else {
              callback(new Error(this.$t('interdisciplinaryManagement.pleaseNumber')))
          }
      },
      validateCannotCon(rule, value, callback) {
          let regEn = /[`$]/im
          if (regEn.test(value)) {
              return callback(new Error(this.$t('identificationToDoList.cannotContain')))
          } else if (value === '') {
              return callback()
          } else {
              return callback()
          }
      },
      postApproveAgree(date) {
          interAcaConferenceApi.overseasCollege(date).then(res => {
              if (res.data.list.length > 0) {
                  res.data.list.forEach(el => {
                      this.options.nameSchool.push({
                          value: el.id,
                          label: el.collegeName,
                          nationName: el.nationName
                      })
                      this.options.englisNameSchool.push({
                          value: el.id,
                          label: el.collegeNameEn,
                          nationName: el.nationName
                      })
                  })
              }
          })
      },
      changeEnglisNameSchool(val) {
          this.options.englisNameSchool.forEach(el => {
              if (val == el.value) {
                  this.queryForm.country = el.nationName
              }
          })
      },
      reback() {
          this.$emit('change-exam')
      },
    }
    
}
</script>